; example2.nsi
;
; This script is based on example1.nsi, but it remember the directory, 
; has uninstall support and (optionally) installs start menu shortcuts.
;
; It will install example2.nsi into a directory that the user selects,

;--------------------------------

; The name of the installer
Name "Reflexis"

; The file to write
OutFile "reflexis-0.99.exe"

BrandingText "it-raum reflexis"

Icon "installer.ico"

; The default installation directory
InstallDir $PROGRAMFILES\Reflexis

; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\Reflexis" "Install_Dir"

;--------------------------------

; Pages

Page components
Page directory
Page instfiles

UninstPage uninstConfirm
UninstPage instfiles

;--------------------------------

; The stuff to install
Section "Reflexis (required)"

  SectionIn RO
  
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Put file there
  File "..\release\reflexis.exe"
  File "..\lib\QtGui4.dll"
  File "..\lib\QtSvg4.dll"
  File "..\lib\QtXml4.dll"
  File "..\lib\krb5_32.dll"
  File "..\lib\libiconv-2.dll"
  File "..\lib\libpq.dll"
  File "..\lib\QtSql4.dll"
  File "..\lib\QtCore4.dll"
  File "..\lib\comerr32.dll"
  File "..\lib\libeay32.dll"
  File "..\lib\libintl-2.dll"
  File "..\lib\ssleay32.dll"
  File "..\lib\msvcr80.dll"
  File "..\lib\msvcp80.dll"
  File "..\lib\Microsoft.VC80.CRT.manifest"
  File "..\lib\qt.conf"
  
  SetOutPath $INSTDIR\plugins\iconengines
  
  File "..\lib\plugins\iconengines\qsvg4.dll"
  
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\Reflexis "Install_Dir" "$INSTDIR"
  
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reflexis" "DisplayName" "Reflexis"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reflexis" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reflexis" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reflexis" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
  
SectionEnd

; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"

  CreateDirectory "$SMPROGRAMS\Reflexis"
  CreateShortCut "$SMPROGRAMS\Reflexis\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\Reflexis\Reflexis.lnk" "$INSTDIR\reflexis.exe" "" "$INSTDIR\reflexis.exe" 0
  
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Reflexis"
  DeleteRegKey HKLM SOFTWARE\NSIS_Reflexis

  ; Remove files and uninstaller
  Delete $INSTDIR\reflexis.exe
  Delete $INSTDIR\QtGui4.dll
  Delete $INSTDIR\QtSvg4.dll
  Delete $INSTDIR\QtXml4.dll
  Delete $INSTDIR\krb5_32.dll
  Delete $INSTDIR\libiconv-2.dll
  Delete $INSTDIR\libpq.dll
  Delete $INSTDIR\QtSql4.dll
  Delete $INSTDIR\QtCore4.dll
  Delete $INSTDIR\comerr32.dll
  Delete $INSTDIR\libeay32.dll
  Delete $INSTDIR\libintl-2.dll
  Delete $INSTDIR\ssleay32.dll
  Delete $INSTDIR\uninstall.exe
  Delete $INSTDIR\msvcr80.dll
  Delete $INSTDIR\msvcp80.dll
  Delete $INSTDIR\Microsoft.VC80.CRT.manifest
  Delete $INSTDIR\plugins\iconengines\qsvg4.dll
  Delete $INSTDIR\qt.conf
  Delete $INSTDIR\plugins\iconengines
  Delete $INSTDIR\plugins
  

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\Reflexis\*.*"

  ; Remove directories used
  RMDir "$SMPROGRAMS\Reflexis"
  RMDir "$INSTDIR"

SectionEnd
